﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using OgilvyOne.BLL;
using OgilvyOne.Model;

public partial class admin_manager_modify : AdminBasePage
{

    public string name;
    string user;
    string pwd;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            header.Text = new ColumnBll().LayeridSysColumnNaiv(Layerid);
        }
        this.PopedomValidate(layerid, MOD);

        user = new AdminBasePage().GetSessionUsersModel().Username;
        name = Request.Params["name"];
        UsersModel model = new UsersBll().GetModel(name);
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        if (userpwd.Value == null || userpwd.Value == "")
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), Guid.NewGuid().ToString(), "alert('密码不能为空！');", true);
            return;
        }
        if (userpwd.Value != userpwd1.Value)
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), Guid.NewGuid().ToString(), "alert('两次密码不一样！');", true);
            return;
        }
        UsersModel model = new UsersBll().GetModel(name);
        model.Userpass = MD5.GetMD5(userpwd.Value);
        pwd = userpwd.Value;
        UsersBll bll = new UsersBll();
        if (new UsersBll().Update(model))
        {
            this.insertLog(user + "修改" + name + "的密码为" + pwd);
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), Guid.NewGuid().ToString(), "alert('保存成功！');window.location=\"user_list.aspx?layerid=" + Layerid + "\";", true);
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), Guid.NewGuid().ToString(), "alert('保存失败！');window.location=\"user_list.aspx\";", true);
        }
    }
}

